import request from '@/utils/request'

// 查询职位列表
export function getPositionListPage(data) {
  console.log(data)
  return request({
    url: '/position/all',
    method: 'post',
    data: data
  })
}

// 查询职位
export function getListPage(data) {
  console.log('职位接口:' + data)
  return request({
    url: '/position/list',
    method: 'post',
    data: data
  })
}

// 删除某个职位
export function removePosition(id) {
  console.log(id)
  return request({
    url: '/position/remove',
    method: 'post',
    data: id
  })
}

// 批量删除职位
export function batchRemoveposition(data) {
  console.log(data)
  return request({
    url: '/position/remove',
    method: 'post',
    data: data
  })
}

// 编辑职位
export function editPosition(data) {
  return request({
    url: '/position/edit',
    method: 'post',
    data: {
      positionDes: data.positionDes,
      departmentId: data.departmentDes,
      parentId: data.parentPosition,
      id: data.id
    }
  })
}

// 新增职位
export function addPosition(data) {
  console.log('新增职位：' + data)
  return request({
    url: '/position/add',
    method: 'post',
    data: {
      positionDes: data.positionDes,
      departmentId: data.departmentDes,
      parentId: data.parentPosition
    }
  })
}

// 给职位添加权限
export function addPositionsPermission(positions, positionPermissions) {
  return request({
    url: '/position/add/permission',
    method: 'post',
    data: {
      positions: positions,
      positionPermissions: positionPermissions
    }
  })
}

// 显示权限配置列表
export function getPermissionListPage() {
  return request({
    url: '/permission/tree',
    method: 'get'
  })
}

// 显示上级职位配置列表
export function getPositionsListPage() {
  return request({
    url: '/position/tree',
    method: 'post'
  })
}

// 显示所属部门配置列表
export function getDepartmentListPage() {
  return request({
    url: '/department/getDepartmentTree',
    method: 'get'
  })
}

